<template>
	<view class="publish_wrap">
		<view class="flex nav_wrap">
			<view :class="nav_index == 0 ? 'nav_item active' : 'nav_item'" @click="toNav(0)">全部</view>
			<view :class="nav_index == 1 ? 'nav_item active' : 'nav_item'" @click="toNav(1)">待审核</view>
			<view :class="nav_index == 2 ? 'nav_item active' : 'nav_item'" @click="toNav(2)">已发布</view>
			<view :class="nav_index == 3 ? 'nav_item active' : 'nav_item'" @click="toNav(3)">未通过</view>
		</view>
		<scroll-view scroll-y="true" style="height: calc(100vh - 100rpx);">
			<view class="list_wrap" v-if="list.length > 0">
				<view class="flex-col list-item mt-10" v-for="(item,index) in list" @click="toDetail(item.id)">
					<view class="flex-row justify-between items-center">
						<text class="font_5 row_1" style="width: 80%;">{{ item.title }}</text>
						<view class="flex">
							<view class="flex-col justify-start items-center text-wrapper view" v-if="item.type_id == 1">
								<text class="font_6">供</text>
							</view>
							<view class="flex-col justify-start items-center text-wrapper need" v-if="item.type_id == 2">
								<text class="font_6">需</text>
							</view>
							<view class="flex-col justify-start items-center text-wrapper not" v-if="item.status == 0">
								<text class="font_6">未解决</text>
							</view>
							<view class="flex-col justify-start items-center text-wrapper already" v-if="item.status == 1">
								<text class="font_6">已解决</text>
							</view>
						</view>
					</view>
					<!-- <text class="font_7 mt-14 row_1">{{ item.content }}</text> -->
					<rich-text class="font_7 mt-14 row_1" :nodes="item.content"></rich-text>
					<view class="flex-row justify-between items-center mt-14">
						<view class="flex-row items-center">
							<image class="image_9" :src="ossUrl + item.user_avatar" />
							<text class="font_8 text_10">{{ item.user_name }}</text>
							<view class="section_10"></view>
							<text class="font_8 text_31">{{ item.user_company_name }}</text>
						</view>
						<text class="font_9 text_12">{{ item.updatetime }}</text>
					</view>
				</view>
			</view>
		
			<view v-else style="text-align: center;padding-top: 120rpx;">暂无数据~</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		ossUrl
	} from '@/utils/config.js'
	import {
		taskList
	} from '@/api/home.js'
	export default {
		data() {
			return {
				ossUrl: ossUrl,
				nav_index: 0,
				list: []
			};
		},
		onLoad(options) {
			this.nav_index = options.index
		},
		onShow() {
			this.taskListFun()
		},
		onShareAppMessage(res) { //发送给朋友
			return {
				title: '小程序分享',
				imageUrl: '',
			}
		},
		methods: {
			taskListFun() {
				let obj = {}
				if (this.nav_index != 0) {
					obj = {
						audit_status: this.nav_index == 0 ? '' : this.nav_index - 1
					}
				}
				taskList(obj).then(res => {
					if (res.code == 1) {
						this.list = res.data
					}
				})
			},
			toNav(index) {
				this.nav_index = index
				this.taskListFun()
			},
			toDetail(id) {
				uni.navigateTo({
					url: '/pages/pages-list/publish_detail/publish_detail?id=' + id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.publish_wrap {
	height: 100vh;
	background: #F5F5F5;
	.nav_wrap {
		width: 100vw;
		height: 96rpx;
		align-items: center;
		padding: 0 28rpx;
		background: #fff;
	
		.nav_item {
			font-size: 30rpx;
			color: #989595;
			margin-right: 80rpx;
		}
	
		.active {
			color: #1C41F1;
			font-weight: bold;
			position: relative;
		}
	
		.active::after {
			content: "";
			width: 60rpx;
			border-bottom: 6rpx solid #1C41F1;
			position: absolute;
			bottom: -10rpx;
			left: 50%;
			transform: translate(-50%);
		}
	}


	.list_wrap {
		.list-item {
			width: 690rpx;
			margin: 20rpx auto;
			padding: 22rpx 11.86rpx 16rpx 17.72rpx;
			background-color: #ffffff;
			border-radius: 12rpx;
	
			.font_5 {
				font-size: 30rpx;
				font-family: PingFang SC;
				color: #000000;
			}
	
			.text-wrapper {
				margin-right: 10rpx;
	
				.font_6 {
					font-size: 24rpx;
					font-family: PingFang SC;
					color: #ffffff;
				}
			}
	
			.view {
				padding: 3rpx 7rpx;
				background-color: #70d042;
				border-radius: 4rpx;
			}
	
			.need {
				padding: 3rpx 7rpx;
				background-color: #f8d53a;
				border-radius: 4rpx;
			}
	
			.not {
				padding: 3rpx 7rpx;
				background-color: #999999;
				border-radius: 4rpx;
			}
			.already {
				padding: 3rpx 7rpx;
				border-radius: 4rpx;
				background: #1C41F1;
			}
	
			.font_7 {
				font-size: 24rpx;
				font-family: PingFang SC;
				color: #000000;
			}
	
			.image_9 {
				border-radius: 20rpx;
				width: 40rpx;
				height: 40rpx;
			}
	
			.font_8 {
				font-size: 22rpx;
				font-family: PingFang SC;
				color: #000000;
			}
	
			.text_10 {
				margin-left: 9.08rpx;
			}
	
			.section_10 {
				margin-left: 15.92rpx;
				background-color: #d9d9d9;
				width: 2rpx;
				height: 24rpx;
			}
	
			.text_31 {
				margin-left: 14.84rpx;
			}
	
			.font_9 {
				font-size: 20rpx;
				color: #000000;
			}
	
			.text_12 {
				margin-right: 4rpx;
			}
		}
	}
}
</style>
